//
//  HRLeftMenuHeadView.m
//  Hear
//
//  Created by mac on 2017/3/23.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "HRLeftMenuHeadView.h"
#import "HRCoverImageModel.h"
@interface HRLeftMenuHeadView ()


@end
@implementation HRLeftMenuHeadView

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        WeakSelf
        UIImageView *iconImageView = [UIImageView new];
        iconImageView.contentMode = UIViewContentModeScaleAspectFill;
        iconImageView.clipsToBounds = YES;
        [self addSubview:(self.iconImageView = iconImageView)];
        DDLog(@"%@",ICONNAME);
//        iconImageView.image = [HRCoverImageModel OriginImage:[UIImage imageNamed:ICONNAME] scaleToSize:CGSizeMake(80, 80)];
        
        [HRCoverImageModel OriginImage:[UIImage imageNamed:ICONNAME] scaleToSize:CGSizeMake(80, 80) callBackOriginImage:^(UIImage *originImage) {
            weakSelf.iconImageView.image = originImage;
        }];
        
        iconImageView.layer.cornerRadius = 40;
        iconImageView.clipsToBounds = YES;
        iconImageView.backgroundColor = [UIColor colorWithHexString:ICONCOLOR];
        iconImageView.userInteractionEnabled = YES;
        
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithActionBlock:^(id  _Nonnull sender) {
            if (weakSelf.chageUserInfoBlock){
                weakSelf.chageUserInfoBlock();
            }
        }];
        [iconImageView addGestureRecognizer:tap];
        
        UILabel *nickNameLabel = [UILabel new];
        nickNameLabel.textColor = [UIColor whiteColor];
        nickNameLabel.font = CustomUIFont(15);
        [self addSubview:(self.nickNameLabel = nickNameLabel)];
        nickNameLabel.text = NICKNAME;
        nickNameLabel.textAlignment = 1;
        
        
        UILabel *line = [UILabel new];
        line.backgroundColor = [UIColor whiteColor];
        [self addSubview:line];
        

        
        [iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(weakSelf);
            make.size.mas_equalTo(CGSizeMake(80, 80));
        }];
        
        [nickNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(iconImageView.mas_bottom).offset(10);
            make.centerX.equalTo(weakSelf);
            make.width.equalTo(weakSelf);
            make.height.mas_equalTo(30);
        }];
        
        [line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf).offset(15);
            make.right.equalTo(weakSelf).offset(-15);
            make.bottom.equalTo(weakSelf);
            make.height.mas_equalTo(0.7);
        }];
        
        
        
    }
    return self;
}

@end
